﻿#include "TcpCodec_MCUCtl.h"

#include "TransmitCodec.h"

TcpCodec_MCUCtl::TcpCodec_MCUCtl()
{
  setObjectName(getClassNameFirstLow<TcpCodec_MCUCtl>());
}

TcpCodec_MCUCtl::~TcpCodec_MCUCtl()
{

}

DataPackage_TcpCodec* TcpCodec_MCUCtl::decode(DataPackage_TcpCodec* dataPackageInfo_User)
{
  //数据的前4个字节是目标设备ID
  QByteArray data=dataPackageInfo_User->getData();
  transmitCodec->decode_tcp(*(uint *)data.data(),dataPackageInfo_User->getUserId(),dataPackageInfo_User->getPackageType(),data.mid(4));
  return Q_NULLPTR;
}

TransmitCodec* TcpCodec_MCUCtl::getMCUCodec()const
{
  return transmitCodec;
}

TcpCodec_MCUCtl* TcpCodec_MCUCtl::setMCUCodec(TransmitCodec* const mCUCodec)
{
  this->transmitCodec=mCUCodec;
  printInjection(this,mCUCodec);
  return this;
}

void TcpCodec_MCUCtl::objectAutoInjection(QHash<QString,QObject*>* objMap)
{
  setMCUCodec(getObjFromMap<TransmitCodec>(objMap));
}
